10 REM--------------------------------------------------------------
20 REM IBM-PC  GRAPHICS EDITING PROGRAM           GARY PEEK  4/2/85
30 REM FOR USE WITH AN EPSON FX-80 PRINTER
40 REM -------------------------------------------------------------
50 REM -----INITIALIZATION-----------
60 CLEAR ,12000!:DEF SEG=&H800:REM THESE VALUES ARE SUBJECT TO GUESSWORK!
70 FOR I=0 TO 330:READ B:POKE I,B:NEXT:DEF SEG
80 KEY OFF:FOR A=1 TO 10:KEY A,"":NEXT
90 SCREEN 2:CLS:X=0:Y=0:YYY=190:XXX=638:IDM$="M":GOSUB 1150
100 GOSUB 500
110 REM ------MAIN LOOP-------
120 IN$=INKEY$:IF IN$="" THEN 120
130 IF IN$="*" THEN CLS
140 IF IN$=CHR$(0)+CHR$(75) THEN GOSUB 360:REM LEFT
150 IF IN$=CHR$(0)+CHR$(77) THEN GOSUB 380:REM RIGHT
160 IF IN$=CHR$(0)+CHR$(72) THEN GOSUB 400:REM UP
170 IF IN$=CHR$(0)+CHR$(80) THEN GOSUB 420:REM DOWN
180 IF IN$=CHR$(52) THEN FOR F=1 TO 20:GOSUB 360:NEXT:REM FAST LEFT
190 IF IN$=CHR$(54) THEN FOR F=1 TO 20:GOSUB 380:NEXT:REM FAST RIGHT
200 IF IN$=CHR$(56) THEN FOR F=1 TO 10:GOSUB 400:NEXT:REM FAST UP
210 IF IN$=CHR$(50) THEN FOR F=1 TO 10:GOSUB 420:NEXT:REM FAST DOWN
220 IF IN$=CHR$(0)+CHR$(82) THEN IDM$="I":REM INSERT PIXEL MODE
230 IF IN$=CHR$(0)+CHR$(83) THEN IDM$="D":REM DELETE PIXEL MODE
240 IF IN$=CHR$(13) THEN IDM$="M"        :REM MOVE PIXEL MODE
250 IF IN$=CHR$(84) THEN GOSUB 1010:GOTO 340:REM GO INTO TEXT MODE
260 IF IN$=CHR$(76) THEN GOSUB 620:REM MAKE LINE BETWEEN POINTS
270 IF IN$=CHR$(67) THEN GOSUB 550:REM MAKE A CIRCLE
280 IF IN$=CHR$(70) THEN GOSUB 680:REM FILL AN ENCLOSED AREA
290 IF IN$=CHR$(69) THEN GOSUB 700:REM ERASE AN ENCLOSED AREA
300 IF IN$=CHR$(82) THEN GOSUB 780:REM READ A FILE
310 IF IN$=CHR$(83) THEN GOSUB 720:REM SAVE TO A FILE
320 IF IN$=CHR$(87) THEN GOSUB 530:REM WINDOW THE WORKING AREA
330 IF IN$=CHR$(80) THEN GOSUB 860:REM PRINT THE SCREEN
340 GOTO 120
350 REM -----------------------------
360 GOSUB 450:X=X-1:IF X<0 THEN X=0
370 GOSUB 500:RETURN
380 GOSUB 450:X=X+1:IF X>XXX THEN X=XXX
390 GOSUB 500:RETURN
400 GOSUB 450:Y=Y-1:IF Y<0 THEN Y=0
410 GOSUB 500:RETURN
420 GOSUB 450:Y=Y+1:IF Y>YYY THEN Y=YYY
430 GOSUB 500:RETURN
440 REM -------------------------------OLD PIXEL---
450 IF IDM$="I" THEN PSET(X,Y),1
460 IF IDM$="D" THEN PSET(X,Y),0
470 IF IDM$="M" THEN PSET(X,Y),IDM
480 RETURN
490 REM ----------------------------------------------------------NEW PIXEL---
500 P=POINT(X,Y):IF P=0 THEN PSET (X,Y),1:IDM=0 ELSE PSET(X,Y),0:IDM=1
510 LOCATE 25,6:PRINT Y;:LOCATE 25,15:PRINT X;:RETURN
520 REM -------DRAW A WINDOW-----------
530 LINE (0,0)-(XXX,YYY),,B:RETURN
540 REM -------MAKE A CIRCLE-----------
550 IF CFLAG THEN 580
560 CX=X:CY=Y:CFLAG=-1
570 LOCATE 25,21:PRINT " GRAPHICS       CIRCLE CENTER AT  ROW=";LY;" COL=";LX;"    "::GOTO 600
580 CXC=ABS(CX-X):CYC=ABS(CY-Y):IF CXC>CYC THEN RADIUS=CXC ELSE RADIUS=CYC*2.49
590 CIRCLE (CX,CY),RADIUS,1:CFLAG=0:GOSUB 1150
600 RETURN
610 REM -------MAKE A LINE-----------
620 IF LFLAG THEN 650
630 LX=X:LY=Y:LFLAG=-1
640 LOCATE 25,21:PRINT " GRAPHICS         LINE BEGINS AT  ROW=";LY;" COL=";LX;"    ";:GOTO 660
650 LINE (LX,LY)-(X,Y):LFLAG=0:GOSUB 1150
660 RETURN
670 REM -------FILL AN AREA------------
680 PSET (X,Y),0:PAINT (X,Y),1:RETURN
690 REM ------ERASE AN AREA------------
700 PSET (X,Y),1:PAINT (X,Y),0:RETURN
710 REM -------SAVE FILE---------------
720 LOCATE 25,21:PRINT "SAVE TO WHAT FILE NAME                               ";
730 LOCATE 25,43:INPUT F$:IF F$="" THEN 760
740 LOCATE 25,1:FOR A=1 TO 79:PRINT " ";:NEXT A
750 F$=F$+".IMG":DEF SEG=&HB800:BSAVE F$,0,&H4000:DEF SEG
760 GOSUB 1150:RETURN
770 REM -------READ FILE-----------
780 LOCATE 25,21:PRINT "READ FROM WHAT FILE NAME                             ";
790 LOCATE 25,45:INPUT F$:IF F$="" THEN 820
800 ON ERROR GOTO 830
810 F$=F$+".IMG":CLS:DEF SEG=&HB800:BLOAD F$,0:DEF SEG
820 GOSUB 1150:ON ERROR GOTO 0:RETURN
830 LOCATE 12,32:PRINT "FILE NOT FOUND"
840 FOR A=1 TO 2000:NEXT:RUN
850 REM ---------PRINT-------------------
860 LOCATE 25,1:FOR A=1 TO 79:PRINT " ";:NEXT
870 DEF SEG=&HB800:BSAVE "IMAG1.$$$",4000,4000
880 DEF SEG=&HBA00:BSAVE "IMAG2.$$$",4000,4000
890 DEF SEG=&HB800:BSAVE "IMAG3.$$$",0,&H4000:DEF SEG
900 WIDTH "LPT1:",255
910 LPRINT CHR$(27)+"@";:LPRINT CHR$(27)+"3"+CHR$(24);
920 DEF SEG=&H810:SUB=0:CALL SUB
930 DEF SEG=&H800:SUB=0:CALL SUB
940 CLS:DEF SEG=&HB800:BLOAD "IMAG1.$$$",0
950 DEF SEG=&HBA00:BLOAD "IMAG2.$$$",0
960 DEF SEG=&H810:SUB=0:CALL SUB
970 DEF SEG=&H800:SUB=0:CALL SUB
980 CLS:DEF SEG=&HB800:BLOAD "IMAG3.$$$",0:DEF SEG
990 LPRINT CHR$(27)+"@":LPRINT:LPRINT:LPRINT:LPRINT:LPRINT:GOSUB 1150:RETURN
1000 REM ------TEXT MODE -----
1010 LOCATE 25,21:PRINT "   TEXT     COMMANDS -    ESC = BACK TO GRAPHICS    ";
1020 AX=INT(X/8)+2:AY=INT(Y/8)+2:LOCATE AY,AX:GOTO 1120
1030 IN$=INKEY$:IF IN$="" THEN 1030
1040 IF IN$=CHR$(27) THEN GOSUB 1130:GOSUB 1150:RETURN:REM BACK TO GRAPHICS
1050 IF LEN(IN$)=2 THEN 1080
1060 IF ASC(IN$)>31 AND ASC(IN$)<128 THEN PRINT IN$;
1070 GOTO 1120
1080 IF IN$=CHR$(0)+CHR$(75) THEN GOSUB 1130:PRINT CHR$(29);:REM LEFT
1090 IF IN$=CHR$(0)+CHR$(77) THEN GOSUB 1130:PRINT CHR$(28);:REM RIGHT
1100 IF IN$=CHR$(0)+CHR$(72) THEN GOSUB 1130:PRINT CHR$(30);:REM UP
1110 IF IN$=CHR$(0)+CHR$(80) THEN GOSUB 1130:PRINT CHR$(31);:REM DOWN
1120 PRINT CHR$(22);CHR$(29);:GOTO 1030
1130 PRINT " ";CHR$(29);:RETURN
1140 REM ------PROMPTS---------
1150 LOCATE 25,2:PRINT "ROW=";:LOCATE 25,11:PRINT "COL=";
1160 LOCATE 25,21:PRINT " GRAPHICS   COMMANDS - INS,DEL,RET,T,L,C,F,E,R,S,W,P";
1170 LOCATE 25,6:PRINT Y;:LOCATE 25,15:PRINT X;:RETURN
1180 REM -------MACHINE LANGUAGE PRINTER ROUTINE------------
1190 DATA &H1E,&H06,&H16,&HB8,0,&HB8
1200 DATA &H8E,&HD8,&HBE,0,&H00,&HBB,0,0
1210 DATA &HB2,&H80,&HB5,&H19,&HB1,&H50,&H52,&HBA,0,0
1220 DATA &HB0,&H1B,&HB4,&H00,&HCD,&H17
1230 DATA &HB0,&H4C,&HB4,&H00,&HCD,&H17
1240 DATA &HB0,&H80,&HB4,&H00,&HCD,&H17
1250 DATA &HB0,&H02,&HB4,&H00,&HCD,&H17
1260 DATA &H90,&H90,&H90,&H90,&H90,&H90:REM NOP BECAUSE EPSON REQUIRES
1270 DATA &H90,&H90,&H90,&H90,&H90,&H90:REM FEWER CHARACTERS TO SPEC.
1280 DATA &H5A,&HB4,&H00
1290 DATA &H8A,0,&H22,&HC2,&H74,3,&H80,&HC4,&H80
1300 DATA &H8A,&H80,0,&H20,&H22,&HC2,&H74,3,&H80,&HC4,&H40
1310 DATA &H8A,&H40,&H50,&H22,&HC2,&H74,3,&H80,&HC4,&H20
1320 DATA &H8A,&H80,&H50,&H20,&H22,&HC2,&H74,&H08,&H80,&HC4,&H10,&HEB,&H03,&H90
1330 DATA &H75,&HA5
1340 DATA &H8A,&H80,&HA0,0,&H22,&HC2,&H74,3,&H80,&HC4,8
1350 DATA &H8A,&H80,&HA0,&H20,&H22,&HC2,&H74,3,&H80,&HC4,4
1360 DATA &H8A,&H80,&HF0,0,&H22,&HC2,&H74,3,&H80,&HC4,2
1370 DATA &H8A,&H80,&HF0,&H20,&H22,&HC2,&H74,&H03,&H80,&HC4,1
1380 DATA &H52,&HBA,0,0,&H8A,&HC4,&HB4,&H00,&HCD,&H17,&H5A
1390 DATA &HD0,&HCA,&H80,&HFA,&H80,&H75,&H92,&H43,&HFE,&HC9,&H75,&H8D
1400 DATA &H52,&HBA,0,0,&HB0,&H0A,&HB4,&H00,&HCD,&H17,&H5A
1410 DATA &H81,&HC3,&HF0,&H00,&HFE,&HCD,&H75,&HA8
1420 DATA &HBA,0,0,&HB0,&H0D,&HB4,0,&HCD,&H17
1430 DATA &H90,&H90,&H90,&H90,&H90,&H90:REM NOP BECAUSE EPSON REQUIRES
1440 DATA &H90,&H90,&H90,&H90,&H90,&H90:REM ONE LESS LF & CR
1450 DATA &H17,&H07,&H1F,&HCA,0,0
1460 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
1470 REM *************************
1480 REM SCREEN CONVERSION ROUTINE
1490 DATA &H1E,&H06,&H16,&HB8,&H00,&HB8,&H8E,&HD8
1500 DATA &HBE,&H9F,&H2F,&HBF,&H3F,&H1F
1510 DATA &HB1,&H50,&HB5,&H00,&H8A,&H04,&H88,&H05
1520 DATA &H88,&H85,&H00,&H20,&H4E,&H4F
1530 DATA &HFE,&HC9,&H75,&HF2,&HB1,&H50
1540 DATA &H80,&HFD,&H01,&H74,&H0A
1550 DATA &HB5,&H01,&HF7,&HD6,&H81,&HC6,&HB0,&H1F,&HF7,&HD6,&H75,&H06
1560 DATA &HB5,&H00,&H81,&HC6,&H00,&H20
1570 DATA &H81,&HFF,&HFF,&HFF,&H75,&HD3
1580 DATA &H17,&H07,&H1F,&HCA,0,0
1590 DATA 0,0,0,0,0,0,0,0,0,0
